/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.machineryrental.weblayer.editors;

import cz.muni.fi.pa165.machineryrental.dto.CustomerDTO;
import cz.muni.fi.pa165.machineryrental.service.CustomerService;
import java.beans.PropertyEditorSupport;

/**
 *
 * @author jostri
 */
public class CustomerEditor extends PropertyEditorSupport {
	
	
	private final CustomerService customerService;
	
	public CustomerEditor(CustomerService customerService) {
		this.customerService = customerService;
	}
 
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		CustomerDTO customer = this.customerService.getById(Long.parseLong(text));
		setValue(customer);
	}
	
}
